// hyb_yl/twosubpages/pages/publicProblems/publicProblems.js
var app = getApp()
var adds = {};
Page({

  /**
   * 页面的初始数据
   */
  data: {
    depar: ["全部", "皮肤科", "儿科", "妇产科", "泌尿外科", "骨科", "消化内科", "性病科", "口腔科", "耳鼻咽喉科", "眼科", "呼吸内科", "普通内科", "感染科 传染科", "内分泌科", "心血管内科", "神经内科", "感染科 传染科", "内分泌科", "心血管内科", "神经内科"],
    tabindex: 0,
    prolist: ['全部', '感冒', '过敏', '痔疮', '焦虑障碍', '湿疹', '支气管炎', '肺炎链球菌严', '糖尿病', '焦虑障碍', '湿疹', '支气管炎', '肺炎链球菌严', '糖尿病'],
    proain: false,
    isshow: 1,
    showt: '展开',
    proaList: [
      {
        "title": '胃不舒服爱打嗝怎么办？是否要做肠镜？',
        "pho": '../../../images/touxiang.png',
        "name": '魏巍',
        "tx": '主治医师',
        "helppho": 922
      },
      {
        "title": '胃不舒服爱打嗝怎么办？是否要做肠镜？',
        "pho": '../../../images/touxiang.png',
        "name": '魏巍',
        "tx": '主治医师',
        "helppho": 922
      },
      {
        "title": '胃不舒服爱打嗝怎么办？是否要做肠镜？',
        "pho": '../../../images/touxiang.png',
        "name": '魏巍',
        "tx": '主治医师',
        "helppho": 922
      },
      {
        "title": '胃不舒服爱打嗝怎么办？是否要做肠镜？',
        "pho": '../../../images/touxiang.png',
        "name": '魏巍',
        "tx": '主治医师',
        "helppho": 922
      },
    ],
    deparshow: false,
    communityListOne: [],
  },
  departab: function (e) {
    // console.log(e);
    const index = e.currentTarget.dataset.dex;
    this.setData({
      tabindex: index
    })
  },
  opend: function () {
    if (this.data.isshow == 0) {
      this.setData({
        isshow: 1,
        showt: '展开'
      })
    } else {
      this.setData({
        isshow: 0,
        showt: '收起'
      })
    }
  },
  proaInfor: function () {
    wx.navigateTo({
      url: '/hyb_yl/twosubpages/pages/publicProblemsInfor/publicProblemsInfor',
    })
  },
  deparlist: function () {
    if (this.data.deparshow) {
      this.setData({
        deparshow: false
      })
    } else {
      this.setData({
        deparshow: true
      })
    }
  },
  departabs: function (e) {
    // console.log(e);
    const index = e.currentTarget.dataset.dex;
    this.setData({
      tabindex: index,
      deparshow: false
    })
  },
  scrolltoupper: function (e) {
    console.log(e);
  },
  toLike: function (a) {
    var e = this;
    let communityListOne = e.data.communityListOne;
    var n = a.currentTarget.dataset.index
    var a_id = a.currentTarget.dataset.a_id
    var openid = wx.getStorageSync('openid')
    if (communityListOne[n].dianzan == 0) {
      app.util.request({
        'url': 'entry/wxapp/share.userdianz',
        data: {
          parentid: a_id,
          openid: openid,
        },
        success: function (res) {
          console.log(res)

        }
      })
      wx.showToast({
        title: "点赞成功",
        icon: "none",
        duration: 1500,
        success: function () {
          var dianzan = "communityListOne[" + n + "].dianzan"
          console.log(dianzan)
          e.setData({
            [dianzan]: 1
          })
        }
      });

    } else {
      wx.showToast({
        title: "点赞是严肃的，不可以反悔哦！",
        icon: "none",
        duration: 1500
      });
    }
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    app.util.request({
      url: 'entry/wxapp/share.remen',
      data: {
        openid: wx.getStorageSync('openid'),
        state: 0
      },
      success: function (res) {
        console.log(res)
        that.setData({
          communityListOne: res.data,
        })
      }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})